package org.geektimes.projects.user.validator.bean.validation;

import java.util.regex.Pattern;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.lang.StringUtils;

public class PhoneValidator implements ConstraintValidator<PhoneValid, String> {

	@Override
	public void initialize(PhoneValid constraintAnnotation) {
	}

	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
		if (!StringUtils.isEmpty(value))
			return Pattern.matches("^\\d{11}$", value);
		return false;
	}

}
